package com.example.demo.service;

import com.example.demo.entity.Userinfo;
import com.example.demo.entity.VO.UserinfoSecret;
import com.example.demo.entity.VO.UserinfoV0;
import com.example.demo.mapper.UserMapper;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.jws.soap.SOAPBinding;

/**
 * Created with IntelliJ IEDA.
 * Description:
 * User:86186
 * Date:2023-08-28
 * Time:20:10
 */
@Service
public class UserService {

    @Autowired
    private UserMapper userMapper;

    /**
     * 添加用户
     */
    public int addUser(Userinfo userinfo){
        return userMapper.addUser(userinfo);
    }
    /**
     * 得到用户信息通过用户名
     */
    public Userinfo getUserByName(String username){
        return userMapper.getUserByName(username);
    }
    /**
     * 得到用户信息通过用户id
     */
    public Userinfo getUserById(Integer id){
        return userMapper.getUserById(id);
    }
    /**
     * 得到用户 state 通过用户名
     */
    public Integer getStateByName(String username){
        return userMapper.getStateByName(username);
    }

    /**
     * 修改用户state信息
     */
    public Integer updateUserStatefoById(Integer state,Integer id){
        return userMapper.updateUserStatefoById(state,id);
    }
    /**
     * 修改用户信息
     */
    public Integer updateUserinfo(UserinfoV0 userinfoV0){
        return userMapper.updateUserinfo(userinfoV0);
    }

    /**
     * 得到用户 gitee地址
     */
    public String getGitee(Integer id){
        return userMapper.getGitee(id);
    }

    public String getUsername(Integer id){
        return userMapper.getUsername(id);
    }
    /**
     * 得到用户信息
     */
    public UserinfoV0 showUserInfo(Integer id){
        return userMapper.showUserInfo(id);
    }

    /**
     * 修改用户头像
     */
    public Integer upLodePhoto(String photo,Integer uid){
        return userMapper.upLodePhoto(photo,uid);
    }

    /**
     * 添加密保
     */
    public Integer addQuestion(Integer id,String question,String answer){
        return userMapper.addQuestion(id,question,answer);
    }

    /**
     * 得到密保问题
     */
    public UserinfoSecret getQuestion(Integer uid){
        return userMapper.getQuestion(uid);
    }

    /**
     * 确认密保答案
     */
    public String checkAnswer(Integer uid){
        return userMapper.checkAnswer(uid);
    }

    /**
     * 修改用户密码
     */
    public Integer updateUserSecret(String password,Integer id){
        return userMapper.updateUserSecret(password,id);
    }

    /**
     * 通过博客id查找用户id
     * @param id
     * @return
     */
    public int getUserUidByid(Integer id) {
        return userMapper.getUserUidByid(id);
    }
}
